home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games Special 4 / THE BEST OF SELECT Games Special 4 (Select CD-ROM)(1996).iso / dosgames / abuse / lisp / ant.lsp next >
Lisp/Scheme  |  1995-09-13  |  17KB  |  619 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4. (setq ant_tints (make-array 11 :initial-contents (list 
  5.                         (def_tint "art/tints/ant/green.spe")
  6.                         (def_tint "art/tints/ant/blue.spe") 
  7.                         (def_tint "art/tints/ant/brown.spe")
  8.                         (def_tint "art/tints/ant/egg.spe")
  9.                         (def_tint "art/tints/ant/yellow.spe")
  10.                         (def_tint "art/tints/ant/mustard.spe")
  11.                         (def_tint "art/tints/ant/orange.spe")
  12.                         (def_tint "art/tints/ant/gray.spe")
  13.                         normal_tint
  14.                         normal_tint
  15.                         normal_tint
  16.                         )))
  17.  
  18. /* 
  19. ------ this code has been compiled --------
  20. (defun no_fall_move (xm ym but)
  21.   (move xm ym but))
  22.   (if (not (eq (gravity) 0))         ;; if we are in the air don't check for no fall
  23.       (move xm ym but)
  24.     (let ((oldx (x))
  25.       (oldy (y))
  26.           (ret (move xm ym but)))
  27.       (if (try_move 0 5)
  28.       (progn
  29.         (set_x oldx)
  30.         (set_y oldy)
  31.         (set_xacel 0)
  32.         (set_state stopped)
  33.         (set_xv 0)
  34.         (set_gravity 0)
  35.         0)
  36.     ret))))
  37.         
  38.       
  39. (defun will_fall_if_jump ()
  40.   nil)
  41.   (let ((dist (* (abs (get_ability jump_yvel)) (get_ability jump_xvel)))
  42.     (oldx (x))
  43.     (oldy (y))
  44.     )
  45.     (if (> (direction) 0)
  46.     (set_x (+ (x) dist))
  47.       (set_x (- (x) dist)))
  48.     (if (try_move 0 5)
  49.     (progn
  50.       (set_x oldx)
  51.       (set_y oldy)
  52.       T)
  53.       (progn
  54.     (set_x oldx)
  55.       (set_y oldy)
  56.     nil))))
  57. ^^^^^^ this code has been compiled ^^^^^^^^
  58. */
  59.  
  60.  
  61. (defun strait_rocket_ai ()
  62.   (set_course (aistate) 
  63.           (select difficulty
  64.               ('easy    12)
  65.               ('medium  15)
  66.               ('hard    17)
  67.               ('extreme 22) ))
  68.   (set_frame_angle 0 359 (aistate))
  69.   (let ((stat (bmove nil)))
  70.     (if (eq stat T)
  71.     T
  72.     (progn
  73.       (if (not (eq stat nil))
  74.       (progn 
  75.         (add_object EXPLODE3 (+ (x) (random 5)) (+ (y) (random 5)) 0)
  76.         (add_object EXPLODE2 (+ (x) (random 5)) (+ (y) (random 5)) 2)
  77.         (add_object EXPLODE3 (- (x) (random 5)) (- (y) (random 5)) 1)
  78.         (add_object EXPLODE3 (- (x) (random 5)) (- (y) (random 5)) 2)
  79.         (hurt_radius (x) (+ (y) 20) 25 15 nil 10))
  80.     (let ((myself (me)))
  81.       (with_object (add_object EG_EXPLO (x) (y)) (user_fun myself (car stat)))))
  82.       nil))))
  83.     
  84.  
  85. (def_char STRAIT_ROCKET
  86.   (funs (ai_fun strait_rocket_ai))
  87.   (range 10000 10000)
  88.   (flags (unlistable T))
  89.   (states "art/missle.spe" (stopped    (seq "b32r" 1 32))))
  90.  
  91. (defun animate_ai () (next_picture))
  92.  
  93. (defun eg_explo_ufun (creator block_flags)
  94.   (set_direction (with_object creator (direction)))
  95.   (if block_flags
  96.       (if (or (blocked_left block_flags) (blocked_right block_flags))
  97.       (set_state blocking))))
  98.      
  99. (def_char EG_EXPLO
  100.   (funs (ai_fun   animate_ai)
  101.     (user_fun eg_explo_ufun))
  102.   (range 10000 10000)
  103.   (flags (unlistable T))
  104.   (states "art/missle.spe"
  105.       (stopped  (seq "bifl" 1 4))
  106.       (blocking (seq "bilw" 1 4))))
  107.  
  108. /* 
  109. ------ this code has been compiled --------
  110. (defun alien_wait_time ()
  111.   (select difficulty 
  112.       ('easy    6)
  113.       ('medium  4)
  114.       ('hard    2)
  115.       ('extreme 1)))
  116.  
  117. (defun can_hit_player ()
  118.   (let ((firex (+ (x) (* (direction) 15)) )
  119.     (firey (- (y) 15))
  120.     (playerx (with_object (bg) (x)))
  121.     (playery (- (with_object (bg) (y)) 15)))
  122.     (can_see firex firey playerx playery nil)))
  123.  
  124. (defun not_ant_congestion ()
  125.   (if (> (direction) 0)
  126.       (if (find_object_in_area (+ (x) 23) (- (y) 20) (+ (x) 30) (+ (y) 20) (list ANT_ROOF))
  127.       nil
  128.     T)
  129.     (if (find_object_in_area (- (x) 30) (- (y) 20) (- (x) 23) (+ (y) 20) (list ANT_ROOF))
  130.     nil
  131.       T)))
  132.       
  133.       
  134. (defun roof_above () (not (can_see (x) (y) (x) (- (y) 120) nil)))
  135.  
  136. (defun fire_at_player ()
  137.   (let ((firex (+ (x) (* (direction) 15)) )
  138.     (firey (- (y) 15))
  139.     (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 8))))
  140.     (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2)))))
  141.     
  142.     (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
  143.     (progn
  144.       (let ((angle (atan2 (- firey playery)
  145.                   (- playerx firex))))
  146.         (fire_object (me) (aitype) firex firey angle (bg))
  147.         (set_state weapon_fire))
  148.  
  149.       ))))
  150.  
  151. (defun ant_dodge ()
  152.   (if (eq need_to_dodge 1)
  153.       (progn 
  154.     (setq need_to_dodge 0)
  155.     (if (eq (random 2) 1)
  156.         (progn
  157.           (set_state stopped)
  158.           (go_state 6))         ;; jump at player
  159.       (if (roof_above)
  160.           (progn            
  161.         (set_yvel -17)  ;; jump up  
  162.         (set_xvel 0)
  163.         (go_state 12))
  164.         (progn
  165.           (set_yvel -12)  ;; long jump
  166.           (set_xvel (* (direction) 20))
  167.           (set_aistate 6))))
  168.     T
  169.     nil)))
  170.  
  171. (defun scream_check ()
  172.   (if (can_see (x) (y) (with_object (bg) (x)) (with_object (bg) (y)) nil)
  173.       (progn
  174.     (if (or (eq no_see_time 0) (> no_see_time 20))
  175.       (play_sound ASCREAM_SND 127 (x) (y)))
  176.     (setq no_see_time 1))
  177.     (setq no_see_time (+ no_see_time 1))))
  178.  
  179. (defun ant_ai ()
  180.       (push_char 30 20)
  181.       (if (or (eq (state) flinch_up) (eq (state) flinch_down))
  182.       (progn (next_picture) T)
  183.     (progn
  184.  
  185.       (select (aistate)
  186.           (0   (set_state hanging)
  187.                (if (eq hide_flag 0)
  188.                (set_aistate 15)
  189.              (set_aistate 16)))
  190.  
  191.           (15 ;; hanging on the roof waiting for the main character           
  192.            (if (next_picture) T (set_state hanging))
  193.            (if (if (eq (total_objects) 0);; no sensor, wait for guy
  194.                (and (< (distx) 130) (< (y) (with_object (bg) (y))))
  195.              (not (eq (with_object (get_object 0) (aistate)) 0)))
  196.                (progn 
  197.              (set_state fall_start)             (set_direction (toward))
  198.              (set_aistate 1))))
  199.  
  200.           (16 ;; hiding
  201.            (set_state hiding)
  202.            (if (if (eq (total_objects) 0);; no sensor, wait for guy
  203.                (and (< (distx) 130) (< (y) (with_object (bg) (y))))
  204.              (not (eq (with_object (get_object 0) (aistate)) 0)))
  205.                (progn 
  206.              (set_state fall_start)             (set_direction (toward))
  207.              (set_aistate 1))))
  208.  
  209.           (1 ;; falling down
  210.            (set_state falling)
  211.            (scream_check)
  212.            (if (blocked_down (move 0 0 0))
  213.                (progn
  214.              (set_state landing)
  215.              (play_sound ALAND_SND 127 (x) (y))
  216.              (set_aistate 9))))
  217.  
  218.           (9 ;; landing / turn around (gerneal finish animation state)
  219.            (if (next_picture) T
  220.              (if (try_move 0 2)    
  221.              (progn
  222.                (set_gravity 1)
  223.                (set_aistate 1))
  224.                (progn (set_state stopped)              
  225.                   (go_state 2)))))  ;; running
  226.  
  227.           (2 ;; running
  228.            (scream_check)
  229.            (if (eq (random 20) 0) (setq need_to_dodge 1))
  230.            (if (not (ant_dodge))
  231.              (if (eq (facing) (toward))
  232.              (progn
  233.                (next_picture)
  234.                (if (and (eq (random 5) 0) (< (distx) 180) (< (disty) 100) (can_hit_player))
  235.                    (progn
  236.                  (set_state weapon_fire)
  237.                  (set_aistate 8))  ;; fire at player
  238.                  (if (and (< (distx) 100) (> (distx) 10) (eq (random 5) 0))
  239.                  (set_aistate 4)  ;; wait for pounce
  240.  
  241.                    (if (and (> (distx) 140)
  242.                     (not_ant_congestion)
  243.                     (not (will_fall_if_jump)))
  244.                    (set_aistate 6)
  245.  
  246.                  (if (> (direction) 0)
  247.                      (if (and (not_ant_congestion) (blocked_right (no_fall_move 1 0 0)))
  248.                      (set_direction -1))
  249.                    (if (and (not_ant_congestion) (blocked_left (no_fall_move -1 0 0)))
  250.                        (set_direction 1)))))))
  251.                (progn
  252.                  (set_direction (toward))
  253.                  (set_state turn_around)
  254.                  (set_aistate 9)))))
  255.           
  256.           (4 ;; wait for pounce
  257.            (if (ant_dodge) T
  258.              (progn
  259.                (set_state pounce_wait)
  260.                (move 0 0 0)
  261.                (if (> (state_time) (alien_wait_time))
  262.                (progn
  263.                  (play_sound ASLASH_SND 127 (x) (y))
  264.                  (set_state stopped)
  265.                  (go_state 6))))))
  266.  
  267.           (6 ;; jump          
  268.            (setq need_to_dodge 0)
  269.            (if (blocked_down (move (direction) -1 0))
  270.                (progn
  271.              (set_aistate 2))))
  272.  
  273.           (8 ;; fire at player
  274.            (if (ant_dodge) T             
  275.              (if (eq (state) fire_wait)
  276.              (if (next_picture)
  277.                  T
  278.                (progn
  279.                  (fire_at_player)
  280.                  (set_state stopped)
  281.                  (set_aistate 2)))
  282.                (set_state fire_wait))))
  283.  
  284.           (12 ;; jump to roof
  285.            (setq need_to_dodge 0)
  286.            (set_state jump_up)
  287.            (set_yvel (+ (yvel) 1))
  288.            (set_xacel 0)
  289.            (let ((top (- (y) 31))
  290.              (old_yvel (yvel))
  291.              (new_top (+ (- (y) 31) (yvel))))
  292.              (let ((y2 (car (cdr (see_dist (x) top (x) new_top)))))
  293.                (try_move 0 (- y2 top) nil)
  294.                (if (not (eq y2 new_top))
  295.                (if (> old_yvel 0)
  296.                  (progn
  297.                    (set_state stopped)
  298.                    (set_aistate 2))
  299.                (